// pages/shopsRoom/shopsRoom.js
const httpRequest = require('../../utils/http_utils.js')
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    rowguid: '', //接口数据
    name: '',
    value: '',
    room: '',
    businessPerson: '',
    phone: '',
    RegionGuid: '',
    BuildingGuid: '',
    FloorGuid: '',
    RoomGuid: '',
    dataList: [], //数据集合
    params:'',//input参数
    info: '',//提示信息
    title: '搜索房间',
    customHeight: 0, //自定义高度
  },

  initdata: function () {
    var that = this;
    that.setData({
      dataList:[]
    })
    var param = {
      PageSize: 15,
      CurrentPage: 1,
      param: that.data.params,
    }
    httpRequest.GetValidateRequest(httpRequest.apiInfo.Project_GetHourseRoomMobileApi, param, function (data) {
      console.log(JSON.stringify(data) + "________________结果")
      if (data.Data.length > 0) {
        that.setData({
          dataList:data.Data
        })
      }
    }, function (err) {

    })
    
  },

  getInput:function(e){
    this.setData({
      params: e.detail.value
    })
    this.initdata();
  },

  radioChange: function(e){
    console.log(this.data.dataList[e.detail.value])
    this.setData({
      info: '你选择了:' + this.data.dataList[e.detail.value].room
    })
    var pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      RoomInfo: this.data.dataList[e.detail.value],
      room: this.data.dataList[e.detail.value].room,
      BusinessGuid: this.data.dataList[e.detail.value].rowguid,
      WorkPlaceRoomNames: this.data.dataList[e.detail.value].room,
      roomOnlyGuid: this.data.dataList[e.detail.value].RoomGuid,
    })
    
    //临时添加，需要修改
    setTimeout(function(){
      wx.navigateBack();
    },1500)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      customHeight: ((app.globalData.titleBarHeight + app.globalData.statusBarHeight) * 2) + 120
    })
    this.initdata();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})